package edu.gyc.collectionhomework;

import java.util.ArrayList;
import java.util.List;

class Whore extends Object{
    private int id;
    private String name;
    private int price;

    public Whore(int id, String name, int price) {
        this.id = id;
        this.name = name;
        this.price = price;
    }

    @Override
    public String toString() {
        return "Whore{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", price=" + price +
                '}';
    }
}

public class Hi {
    public static void main(String[] args) {
        List<?> list = null;
        list = new ArrayList<String>();
        list = new ArrayList<Double>();
// list.add(3);//编译不通过
        list.add(null);
        List<String> l1 = new ArrayList<String>();
        List<Integer> l2 = new ArrayList<Integer>();
        List<Whore> l3 = new ArrayList<>();
        l1.add("尚硅谷");
        l2.add(15);
        read(l1);
        l3.add(new Whore(1, "徐睿", 899));
        read(l2);
        read(l3);
        adds(l3);
    }

    public static void read(List<?> list) {
        for (Object o : list) {
            System.out.println(o);
        }
    }

    public static void adds(List<? extends Object> list) {
        for (Object o : list) {
            System.out.println(o);
        }
        //list.add(whores);
    }
}
